package com.cn.ccp.bean;

import org.apache.log4j.Logger;


/**
 * 
 * @author Administrator
 */
public abstract class PageItemBean {
	private Logger log = Logger.getLogger(PageItemBean.class);
	private int currentPage=1;			 
	protected int pageSize=10;					 
	private int itemCount=0;				 

	public int getCountPage() {				 
		int countPage=0;
		countPage=itemCount/pageSize;
		if(itemCount%pageSize!=0)
		{
			countPage++;
		}
		log.info("itemCount = "+itemCount+" | pageSize = "+pageSize + " | countPage = "+countPage);
		return countPage;
	}
	public abstract void getpagedetail();
	
	public int getCurrentPage() {
		
		return currentPage;
	}
	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}
	public int getPageSize() {
		return pageSize;
	}
	public void setPageSize(int pageSize) {
		log.info("----pageSize = "+pageSize);
		this.pageSize = pageSize;
	}
	public String nextPage()
	{
		
//		log.info("----currentPage = "+currentPage);
//		log.info("----itemCount = "+itemCount);
//		log.info("----getCountPage() = "+getCountPage());
//		log.info("----pageSize = "+pageSize);
		
		if(currentPage+1<=getCountPage())
			currentPage++;
		log.info("----currentPage = "+currentPage);
		getpagedetail();
		return "";
	}
	public String provPage()
	{
		if(currentPage>1)
			currentPage--;
		getpagedetail();
		return "";
	}
	public String firstPage()
	{
			currentPage=1;
			getpagedetail();
			return "";
	}
	
	public String refresh(){
		this.getpagedetail();
		return "";
	}
	public String lastPage()
	{
		currentPage=getCountPage();
		getpagedetail();
		return "";
	}
	public int getItemCount() {
		return itemCount;
	}
	public void setItemCount(int itemCount) {
		this.itemCount = itemCount;
	}
	public String goCurrentPage()					 
	{
		if(currentPage>getCountPage())
			currentPage=getCountPage();
		if(currentPage<1)
			currentPage=1;
		getpagedetail();
		return "";
			
	}
}
